package com.itheima.reggie.controller;

import com.itheima.reggie.domain.Category;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//分类模块
@RestController     //Response + Controller
public class CategoryController {

    //依赖注入
    @Autowired
    private CategoryService categoryService;

    //查询分类列表
    //Request URL: http://localhost:8081/category/list
    //Request Method: GET
    @GetMapping("/category/list")
    public ResultInfo findAll() {
        //1. 调用service层
        List<Category> list = categoryService.findAll();

        //2. 返回响应
        return ResultInfo.success(list);

    }
}
